Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make the linter config attractive #3486

Merged
merged 8 commits into from
Dec 17, 2022
Merged

Conversation

faddat
Copy link
Member

@faddat faddat commented Nov 22, 2022

Closes: #XXX

What is the purpose of the change

Long ago, I used .golangci.yml in Osmosis to learn how to fully configure golangci-lint.

THis PR aims to fix that, while masking changes that Dev mentioned were unnecessary.

Brief Changelog

  • Make .golangci.yml quality
  • change the Makefile so that there's no longer a need to separately invoke gofumpt

Testing and Verifying

This change is a trivial rework / code cleanup without any test coverage.

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? (yes / no) no
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? (yes / no) no
  • How is the feature or change documented? (not applicable / specification (x/<module>/spec/) / Osmosis docs repo / not documented) not applicable

@faddat faddat requested a review from a team November 22, 2022 14:30
@github-actions github-actions bot added C:app-wiring Changes to the app folder C:CLI C:simulator Edits simulator or simulations C:x/epochs C:x/gamm Changes, features and bugs related to the gamm module. C:x/incentives C:x/lockup C:x/mint C:x/superfluid C:x/tokenfactory C:x/twap Changes to the twap module T:CI C:x/pool-incentives labels Nov 22, 2022
@@ -15,7 +15,7 @@ func SigFigRound(d sdk.Dec, tenToSigFig sdk.Int) sdk.Dec {
// take note of floor div, vs normal div
k := uint64(0)
dTimesK := d
for ; dTimesK.LT(pointOne); k += 1 {
for ; dTimesK.LT(pointOne); k++ {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which linter said this, can we turn it off

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

totally, it's revive's increment-decrement, and can get rid of it :)

.golangci.yml Outdated
# - goerr113 <- disabled due to lack of comprehension
- gofmt
# - gofumpt <- disabled https://github.com/osmosis-labs/osmosis/issues/1309
- gocritic # <- re enable later to catch capitalized local variables
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should delete this, I dont think these are helpful lints.

.golangci.yml Outdated
- gofmt
# - gofumpt <- disabled https://github.com/osmosis-labs/osmosis/issues/1309
- gocritic # <- re enable later to catch capitalized local variables
- gofumpt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets leave this deleted, it doesn't have good IDE support.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with gofumpt, what I have been doing, is using it to replace both goimports and gofmt

if your ide supports golangci-lint, it will now gofumpt automagically.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the lints from gofumpt, I really don't think this is a win to have as overhead on every PR/commit

.golangci.yml Outdated
- gomodguard
- goprintffuncname
# - gosec <- triggers too much for this round and should be re-enabled later
- gosec # <- triggers too much for this round and should be re-enabled later
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be changed in a separate PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes.

.golangci.yml Outdated
# - nlreturn <- disabled as it doesn't auto-fix something simple and doesn't add anything useful
# - noctx <- needs go 1.18 support
# - nolintlint <- disabled because we use nolint in some places
- nolintlint # <- disabled because we use nolint in some places
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets delete this?

Nolints are perfectly fine to have in the codebase.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nolintlint just forces us to

//nolint:whatever per-line, I'd prefer to keep it ?

Basically it is an enforcer of //nolint:whatever hygene.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh gothca

@faddat
Copy link
Member Author

faddat commented Nov 22, 2022

Yes to all, except nolintlint?

Also, for gofumpt... curious what you mean about ide support?

Basically it is now wired into golangci-lint

this reduces the whole affair to -- for example --

golangci-lint run ./... --fix

in vscode, I set it to do that to my workspace on changes.

@faddat faddat marked this pull request as draft November 22, 2022 15:23
@faddat
Copy link
Member Author

faddat commented Nov 23, 2022

After talking to Adam on slack, I think that this pr should be kept super minimal, and expanded after the concentrated liquidity branch is merged.

@faddat
Copy link
Member Author

faddat commented Nov 29, 2022

summary:

  • Makefile and .golangci.yml changed
  • goimports and gofmt dropped in favor of gofumpt, due to the errors above
  • no other changes in terms of which linters we use

@github-actions github-actions bot added C:CLI C:simulator Edits simulator or simulations C:x/lockup and removed C:app-wiring Changes to the app folder C:x/swaprouter C:x/gamm Changes, features and bugs related to the gamm module. labels Dec 5, 2022
@ValarDragon ValarDragon added the V:state/compatible/backport State machine compatible PR, should be backported label Dec 8, 2022
@ValarDragon
Copy link
Member

We have to fix the lint failures on this PR (or comment out those linters and make a new GH issue for them)

@faddat
Copy link
Member Author

faddat commented Dec 12, 2022

totally! sorry I missed that :P

@github-actions github-actions bot added C:app-wiring Changes to the app folder C:x/gamm Changes, features and bugs related to the gamm module. C:x/swaprouter labels Dec 12, 2022
@ValarDragon ValarDragon added V:state/compatible/no_backport State machine compatible PR, depends on prior breaks and removed V:state/compatible/backport State machine compatible PR, should be backported labels Dec 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:app-wiring Changes to the app folder C:CLI C:simulator Edits simulator or simulations C:x/gamm Changes, features and bugs related to the gamm module. C:x/lockup T:CI V:state/compatible/no_backport State machine compatible PR, depends on prior breaks
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants